package cn.gok.testgit;

/**
 * @ClassName test
 * @Description TODO
 * @Author HP
 * @Date 8:22 2022/7/7
 * @Version 1.0
 **/
class Person{
    private String name;
    private int age;
    private String sex;
    private String isMarried;

    public Person(String name, int age, String sex, String isMarried) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.isMarried = isMarried;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getIsMarried() {
        return isMarried;
    }

    public void setIsMarried(String isMarried) {
        this.isMarried = isMarried;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", isMarried='" + isMarried + '\'' +
                '}';
    }
    public static boolean judgeAge(Person p){
        if ("男".equals(p.getSex())){
            return p.getAge()<20;
        }
        if("女".equals(p.getSex())){
            return p.getAge()<19;
        }
        return false;
    }
    public static boolean marryWith(Person p1,Person p2){
        boolean isSuccess = true;
        if(!p1.isMarried.equals("否")&&!p2.isMarried.equals("否")){
            isSuccess=false;
            System.out.println("都不是未婚");
            return  false;
        }
        if(p1.getSex().equals(p2.getSex())){
            isSuccess=false;
            System.out.println("同性不能结婚");
            return false;
        }
        if(!judgeAge(p1)||!judgeAge(p2)){
            System.out.println("无法结婚");
            return true ;
        }

        p1.setIsMarried("否");
        p2.setIsMarried("否");
        System.out.println("结婚成功");
        return true;
    }
}
public class test3 {
    public static void main(String[] args) {
        Person p1 =new Person("123",12,"NAN","否");
        Person p2 =new Person("123",26,"Nv","否");
        System.out.println(Person.marryWith(p1,p2));
    }
}
